﻿#region Copyright(c) 2006 ZO, All right reserved.
// -----------------------------------------------------------------------------
// Copyright(c) 2006 ZO, All right reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//   1.  Redistribution of source code must retain the above copyright notice,
//       this list of conditions and the following disclaimer.
//   2.  Redistribution in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//   3.  The name of the author may not be used to endorse or promote products
//       derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// -----------------------------------------------------------------------------
#endregion


#region Using directives

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using ZO.SmartCore.My4CSharp.Properties;
using ArgumentException= ZO.SmartCore.Core.ArgumentException;
using ArgumentNullException= ZO.SmartCore.Core.ArgumentNullException;

#endregion

namespace ZO.SmartCore.My4CSharp
{
    /// <summary>Provides methods and properties for parsing structured text files.</summary>
    [Browsable(false)]
    [EditorBrowsable(EditorBrowsableState.Advanced)]
    public class TextFieldParser : IDisposable
    {

        #region Constructors
        /// <summary>Initializes a new instance of the TextFieldParser class.</summary>
        /// <param name="stream"><see cref="T:System.IO.Stream"></see>. The stream to be parsed.</param>
        [HostProtection(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
        public TextFieldParser(Stream stream)
        {
            this._CommentTokens = new string[0];
            this._LineNumber = 1;
            this._ErrorLine = "";
            this._ErrorLineNumber = -1;
            this._TextFieldType = FieldType.Delimited;
            this._WhiteSpaceCodes = new int[] { 
            9, 11, 12, 0x20, 0x85, 160, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 
            0x2009, 0x200a, 0x200b, 0x2028, 0x2029, 0x3000, 0xfeff
       };
            this._WhiteSpaceRegEx = new Regex(@"\s", RegexOptions.CultureInvariant);
            this._TrimWhiteSpace = true;
            this._NeedPropertyCheck = true;
            this._Buffer = new char[0x1000];
            this._HasFieldsEnclosedInQuotes = true;
            this._MaxLineSize = 0x989680;
            this._MaxBufferSize = 0x989680;
            this.InitializeFromStream(stream, Encoding.UTF8, true);
        } // TextFieldPars

        /// <summary>Initializes a new instance of the TextFieldParser class.</summary>
        /// <param name="reader"><see cref="T:System.IO.TextReader"></see>. The <see cref="T:System.IO.TextReader"></see> stream to be parsed. </param>
        [HostProtection(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
        public TextFieldParser(TextReader reader)
        {
            this._CommentTokens = new string[0];
            this._LineNumber = 1;
            this._ErrorLine = "";
            this._ErrorLineNumber = -1;
            this._TextFieldType = FieldType.Delimited;
            this._WhiteSpaceCodes = new int[] { 
            9, 11, 12, 0x20, 0x85, 160, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 
            0x2009, 0x200a, 0x200b, 0x2028, 0x2029, 0x3000, 0xfeff
       };
            this._WhiteSpaceRegEx = new Regex(@"\s", RegexOptions.CultureInvariant);
            this._TrimWhiteSpace = true;
            this._NeedPropertyCheck = true;
            this._Buffer = new char[0x1000];
            this._HasFieldsEnclosedInQuotes = true;
            this._MaxLineSize = 0x989680;
            this._MaxBufferSize = 0x989680;
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            } // if
            this._Reader = reader;
            this.ReadToBuffer();
        } // TextFieldParser



        /// <summary>Initializes a new instance of the TextFieldParser class.</summary>
        /// <param name="path">String. The complete path of the file to be parsed.</param>
        [HostProtection(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
        public TextFieldParser(string path)
        {
            this._CommentTokens = new string[0];
            this._LineNumber = 1;
            this._ErrorLine = "";
            this._ErrorLineNumber = -1;
            this._TextFieldType = FieldType.Delimited;
            this._WhiteSpaceCodes = new int[] { 
            9, 11, 12, 0x20, 0x85, 160, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 
            0x2009, 0x200a, 0x200b, 0x2028, 0x2029, 0x3000, 0xfeff
       };
            this._WhiteSpaceRegEx = new Regex(@"\s", RegexOptions.CultureInvariant);
            this._TrimWhiteSpace = true;
            this._NeedPropertyCheck = true;
            this._Buffer = new char[0x1000];
            this._HasFieldsEnclosedInQuotes = true;
            this._MaxLineSize = 0x989680;
            this._MaxBufferSize = 0x989680;
            this.InitializeFromPath(path, Encoding.UTF8, true);
        } // TextFieldParser

        /// <summary>Initializes a new instance of the TextFieldParser class.</summary>
        /// <param name="defaultEncoding"><see cref="T:System.Text.Encoding"></see>. The character encoding to use if encoding is not determined from file. Default is <see cref="P:System.Text.Encoding.UTF8"></see>.</param>
        /// <param name="stream"><see cref="T:System.IO.Stream"></see>. The stream to be parsed.</param>
        [HostProtection(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
        public TextFieldParser(Stream stream, Encoding defaultEncoding)
        {
            this._CommentTokens = new string[0];
            this._LineNumber = 1;
            this._ErrorLine = "";
            this._ErrorLineNumber = -1;
            this._TextFieldType = FieldType.Delimited;
            this._WhiteSpaceCodes = new int[] { 
            9, 11, 12, 0x20, 0x85, 160, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 
            0x2009, 0x200a, 0x200b, 0x2028, 0x2029, 0x3000, 0xfeff
       };
            this._WhiteSpaceRegEx = new Regex(@"\s", RegexOptions.CultureInvariant);
            this._TrimWhiteSpace = true;
            this._NeedPropertyCheck = true;
            this._Buffer = new char[0x1000];
            this._HasFieldsEnclosedInQuotes = true;
            this._MaxLineSize = 0x989680;
            this._MaxBufferSize = 0x989680;
            this.InitializeFromStream(stream, defaultEncoding, true);
        } // TextFieldParser



        /// <summary>Initializes a new instance of the TextFieldParser class.</summary>
        /// <param name="defaultEncoding"><see cref="T:System.Text.Encoding"></see>. The character encoding to use if encoding is not determined from file. Default is <see cref="P:System.Text.Encoding.UTF8"></see>.</param>
        /// <param name="path">String. The complete path of the file to be parsed.</param>
        [HostProtection(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
        public TextFieldParser(string path, Encoding defaultEncoding)
        {
            this._CommentTokens = new string[0];
            this._LineNumber = 1;
            this._ErrorLine = "";
            this._ErrorLineNumber = -1;
            this._TextFieldType = FieldType.Delimited;
            this._WhiteSpaceCodes = new int[] { 
            9, 11, 12, 0x20, 0x85, 160, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 
            0x2009, 0x200a, 0x200b, 0x2028, 0x2029, 0x3000, 0xfeff
       };
            this._WhiteSpaceRegEx = new Regex(@"\s", RegexOptions.CultureInvariant);
            this._TrimWhiteSpace = true;
            this._NeedPropertyCheck = true;
            this._Buffer = new char[0x1000];
            this._HasFieldsEnclosedInQuotes = true;
            this._MaxLineSize = 0x989680;
            this._MaxBufferSize = 0x989680;
            this.InitializeFromPath(path, defaultEncoding, true);
        } // TextFieldParser



        /// <summary>Initializes a new instance of the TextFieldParser class.</summary>
        /// <param name="detectEncoding">Boolean. Indicates whether to look for byte order marks at the beginning of the file. Default is True.</param>
        /// <param name="defaultEncoding"><see cref="T:System.Text.Encoding"></see>. The character encoding to use if encoding is not determined from file. Default is <see cref="P:System.Text.Encoding.UTF8"></see>.</param>
        /// <param name="stream"><see cref="T:System.IO.Stream"></see>. The stream to be parsed.</param>
        [HostProtection(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
        public TextFieldParser(Stream stream, Encoding defaultEncoding, bool detectEncoding)
        {
            this._CommentTokens = new string[0];
            this._LineNumber = 1;
            this._ErrorLine = "";
            this._ErrorLineNumber = -1;
            this._TextFieldType = FieldType.Delimited;
            this._WhiteSpaceCodes = new int[] { 
            9, 11, 12, 0x20, 0x85, 160, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 
            0x2009, 0x200a, 0x200b, 0x2028, 0x2029, 0x3000, 0xfeff
       };
            this._WhiteSpaceRegEx = new Regex(@"\s", RegexOptions.CultureInvariant);
            this._TrimWhiteSpace = true;
            this._NeedPropertyCheck = true;
            this._Buffer = new char[0x1000];
            this._HasFieldsEnclosedInQuotes = true;
            this._MaxLineSize = 0x989680;
            this._MaxBufferSize = 0x989680;
            this.InitializeFromStream(stream, defaultEncoding, detectEncoding);
        } // TextFieldParser



        /// <summary>Initializes a new instance of the TextFieldParser class.</summary>
        /// <param name="detectEncoding">Boolean. Indicates whether to look for byte order marks at the beginning of the file. Default is True.</param>
        /// <param name="defaultEncoding"><see cref="T:System.Text.Encoding"></see>. The character encoding to use if encoding is not determined from file. Default is <see cref="P:System.Text.Encoding.UTF8"></see>.</param>
        /// <param name="path">String. The complete path of the file to be parsed.</param>
        [HostProtection(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
        public TextFieldParser(string path, Encoding defaultEncoding, bool detectEncoding)
        {
            this._CommentTokens = new string[0];
            this._LineNumber = 1;
            this._ErrorLine = "";
            this._ErrorLineNumber = -1;
            this._TextFieldType = FieldType.Delimited;
            this._WhiteSpaceCodes = new int[] { 
            9, 11, 12, 0x20, 0x85, 160, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 
            0x2009, 0x200a, 0x200b, 0x2028, 0x2029, 0x3000, 0xfeff
       };
            this._WhiteSpaceRegEx = new Regex(@"\s", RegexOptions.CultureInvariant);
            this._TrimWhiteSpace = true;
            this._NeedPropertyCheck = true;
            this._Buffer = new char[0x1000];
            this._HasFieldsEnclosedInQuotes = true;
            this._MaxLineSize = 0x989680;
            this._MaxBufferSize = 0x989680;
            this.InitializeFromPath(path, defaultEncoding, detectEncoding);
        } // TextFieldParser



        /// <summary>Initializes a new instance of the TextFieldParser class.</summary>
        /// <param name="detectEncoding">Boolean. Indicates whether to look for byte order marks at the beginning of the file. Default is True.</param>
        /// <param name="leaveOpen">Boolean. Indicates whether to leave stream open when the TextFieldParser object is closed. Default is False.</param>
        /// <param name="defaultEncoding"><see cref="T:System.Text.Encoding"></see>. The character encoding to use if encoding is not determined from file. Default is <see cref="P:System.Text.Encoding.UTF8"></see>.</param>
        /// <param name="stream"><see cref="T:System.IO.Stream"></see>. The stream to be parsed.</param>
        [HostProtection(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
        public TextFieldParser(Stream stream, Encoding defaultEncoding, bool detectEncoding, bool leaveOpen)
        {
            this._CommentTokens = new string[0];
            this._LineNumber = 1;
            this._ErrorLine = "";
            this._ErrorLineNumber = -1;
            this._TextFieldType = FieldType.Delimited;
            this._WhiteSpaceCodes = new int[] { 
            9, 11, 12, 0x20, 0x85, 160, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 
            0x2009, 0x200a, 0x200b, 0x2028, 0x2029, 0x3000, 0xfeff
       };
            this._WhiteSpaceRegEx = new Regex(@"\s", RegexOptions.CultureInvariant);
            this._TrimWhiteSpace = true;
            this._NeedPropertyCheck = true;
            this._Buffer = new char[0x1000];
            this._HasFieldsEnclosedInQuotes = true;
            this._MaxLineSize = 0x989680;
            this._MaxBufferSize = 0x989680;
            this._LeaveOpen = leaveOpen;
            this.InitializeFromStream(stream, defaultEncoding, detectEncoding);
        } // TextFieldParser
        #endregion

        #region Destructor
        /// <summary>
        /// Releases unmanaged resources and performs other cleanup operations before the
        /// <see cref="T:SmartCore.My4CSharp.TextFieldParser"/> is reclaimed by garbage collection.
        /// </summary>
        ~TextFieldParser()
        {
            this.Dispose(false);
        } // ~TextFieldParser

        #endregion

        #region Fields
 /*
         * private const string BEGINS_WITH_QUOTE = "\\G[{0}]*\"";
        private const int DEFAULT_BUFFER_LENGTH = 0x1000;
        private const int DEFAULT_BUILDER_INCREASE = 10;

        private const string ENDING_QUOTE = "\"[{0}]*";
*/
        private Regex _BeginQuotesRegex;
        private char[] _Buffer;
        private int m_CharsRead;
        private string[] _CommentTokens;
        private Regex _DelimiterRegex;
        private string[] _Delimiters;
        private string[] _DelimitersCopy;
        private Regex _DelimiterWithEndCharsRegex;
        private bool _Disposed;
        private bool _EndOfData;
        private string _ErrorLine;
        private long _ErrorLineNumber;
        private int[] _FieldWidths;
        private int[] _FieldWidthsCopy;
        private bool _HasFieldsEnclosedInQuotes;
        private bool _LeaveOpen;
        private int _LineLength;
        private long _LineNumber;
        private int _MaxBufferSize;
        private int _MaxLineSize;
        private bool _NeedPropertyCheck;
        private int _PeekPosition;
        private int _Position;
        private TextReader _Reader;
        private string _SpaceChars;
        private FieldType _TextFieldType;
        private bool _TrimWhiteSpace;
        private int[] _WhiteSpaceCodes;
        private Regex _WhiteSpaceRegEx;
/*
        private const RegexOptions REGEX_OPTIONS = RegexOptions.CultureInvariant;
*/


        private delegate int ChangeBufferFunction();
        #endregion

        #region Events

        #endregion

        #region Operators

        #endregion

        #region Properties
        private Regex BeginQuotesRegex
        {
            get
            {
                if (this._BeginQuotesRegex == null)
                {
                    string text1 = String.Format(CultureInfo.InvariantCulture, "\\G[{0}]*\"", new object[] { this.WhiteSpacePattern });
                    this._BeginQuotesRegex = new Regex(text1, RegexOptions.CultureInvariant);
                } // if
                return this._BeginQuotesRegex;
            } // get
        } // BeginQuotesRegex

        /// <summary>Defines comment tokens. A comment token is a string that, when placed at the beginning of a line, indicates that the line is a comment and should be ignored by the parser.</summary>
        /// <returns>String ().</returns>
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
        public string[] CommentTokens
        {
            get
            {
                return this._CommentTokens;
            } // get
            set
            {
                this.CheckCommentTokensForWhiteSpace(value);
                this._CommentTokens = value;
                this._NeedPropertyCheck = true;
            } // set
        } // CommentTokens

        /// <summary>Defines the delimiters for a text file. </summary>
        /// <returns>String ().</returns>
        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
        public string[] Delimiters
        {
            get
            {
                return this._Delimiters;
            } // get
            set
            {
                if (value != null)
                {
                    ValidateDelimiters(value);
                    this._DelimitersCopy = (string[])value.Clone();
                } // if
                else
                {
                    this._DelimitersCopy = null;
                } // else
                this._Delimiters = value;
                this._NeedPropertyCheck = true;
                this._BeginQuotesRegex = null;
            } // set
        } // Delimiters

        /// <summary>Returns True if there are no non-blank, non-comment lines between the current cursor position and the end of the file.</summary>
        /// <returns>Boolean.</returns>
        public bool EndOfData
        {
            get
            {
                if (this._EndOfData)
                {
                    return this._EndOfData;
                } // if
                if ((this._Reader == null) | (this._Buffer == null))
                {
                    this._EndOfData = true;
                    return true;
                } // if
                if (this.PeekNextDataLine() != null)
                {
                    return false;
                } // if
                this._EndOfData = true;
                return true;
            } // get
        } // EndOfData

        private string EndQuotePattern
        {
            get
            {
                return String.Format(CultureInfo.InvariantCulture, "\"[{0}]*", new object[] { this.WhiteSpacePattern });
            } // get
        } // EndQuotePattern

        /// <summary>Returns the line that caused the most recent <see cref="MalformedLineException"></see> exception.</summary>
        /// <returns>String.</returns>
        public string ErrorLine
        {
            get
            {
                return this._ErrorLine;
            } // get
        } // ErrorLine

        /// <summary>Returns the number of the line that caused the most recent <see cref="MalformedLineException"></see> exception.</summary>
        /// <returns>Long.</returns>
        public long ErrorLineNumber
        {
            get
            {
                return this._ErrorLineNumber;
            } // get
        } // ErrorLineNumber

        /// <summary>Denotes the width of each column in the text file being parsed.</summary>
        /// <returns>Integer ().</returns>
        [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
        public int[] FieldWidths
        {
            get
            {
                return this._FieldWidths;
            } // get
            set
            {
                if (value != null)
                {
                    ValidateFieldWidthsOnInput(value);
                    this._FieldWidthsCopy = (int[])value.Clone();
                } // if
                else
                {
                    this._FieldWidthsCopy = null;
                } // else
                this._FieldWidths = value;
                this._NeedPropertyCheck = true;
            } // set
        } // FieldWidths

        /// <summary>Denotes whether fields are enclosed in quotation marks when parsing a delimited file.</summary>
        /// <returns>Boolean.</returns>
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        public bool HasFieldsEnclosedInQuotes
        {
            get
            {
                return this._HasFieldsEnclosedInQuotes;
            } // get
            set
            {
                this._HasFieldsEnclosedInQuotes = value;
            } // set
        } // HasFieldsEnclosedInQuotes

        /// <summary>Returns the current line number, or returns -1 if no more characters are available in the stream.</summary>
        /// <returns>Integer.</returns>
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        public long LineNumber
        {
            get
            {
                if ((this._LineNumber != -1) && ((this._Reader.Peek() == -1) & (this._Position == this.m_CharsRead)))
                {
                    this.CloseReader();
                } // if
                return this._LineNumber;
            } // get
        } // LineNumber

        /// <summary>Indicates whether the file to be parsed is delimited or fixed-width.</summary>
        /// <returns><see cref="TextFieldParser.TextFieldType"></see>.</returns>
        public FieldType TextFieldType
        {
            get
            {
                return this._TextFieldType;
            } // get
            set
            {
                ValidateFieldTypeEnumValue(value, "value");
                this._TextFieldType = value;
                this._NeedPropertyCheck = true;
            } // set
        } // TextFieldType

        /// <summary>Indicates whether leading and trailing WhiteSpace should be trimmed from field values.</summary>
        /// <returns>Boolean.</returns>
        [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "WhiteSpace")]
        public bool TrimWhiteSpace
        {
            get
            {
                return this._TrimWhiteSpace;
            } // get
            set
            {
                this._TrimWhiteSpace = value;
            } // set
        } // TrimWhiteSpace

        private string WhiteSpaceCharacters
        {
            get
            {
                StringBuilder builder1 = new StringBuilder();
                int[] numArray1 = this._WhiteSpaceCodes;
                for (int num2 = 0; num2 < numArray1.Length; num2++)
                {
                    int num1 = numArray1[num2];

                    char ch1 = (char)(num1);
                    if (!this.CharacterIsInDelimiter(ch1))
                    {
                        builder1.Append(ch1);
                    } // if
                } // for
                return builder1.ToString();
            } // get
        } // WhiteSpaceCharacters

        private string WhiteSpacePattern
        {
            get
            {
                StringBuilder builder1 = new StringBuilder();
                int[] numArray1 = this._WhiteSpaceCodes;
                for (int num2 = 0; num2 < numArray1.Length; num2++)
                {
                    int num1 = numArray1[num2];
                    char ch1 = (char)(num1);
                    if (!this.CharacterIsInDelimiter(ch1))
                    {
                        builder1.Append(@"\u" + num1.ToString("X4", CultureInfo.InvariantCulture));
                    } // if
                } // for
                return builder1.ToString();
            } // get
        } // WhiteSpacePattern
        #endregion

        #region Methods
        private bool ArrayHasChanged()
        {
            int num1;
            int num2;
            switch (this._TextFieldType)
            {
                case FieldType.Delimited:
                    {
                        if (this._Delimiters == null)
                        {
                            return false;
                        } // if
                        num1 = this._DelimitersCopy.GetLowerBound(0);
                        num2 = this._DelimitersCopy.GetUpperBound(0);
                        int num5 = num2;
                        for (int num3 = num1; num3 <= num5; num3++)
                        {
                            if (String.Compare(this._Delimiters[num3], this._DelimitersCopy[num3], true, CultureInfo.InvariantCulture) != 0)
                            {
                                return true;
                            } // if
                        } // for
                        break;
                    } // block
                case FieldType.FixedWidth:
                    {
                        if (this._FieldWidths == null)
                        {
                            return false;
                        } // if
                        num1 = this._FieldWidthsCopy.GetLowerBound(0);
                        num2 = this._FieldWidthsCopy.GetUpperBound(0);
                        int num6 = num2;
                        for (int num4 = num1; num4 <= num6; num4++)
                        {
                            if (this._FieldWidths[num4] != this._FieldWidthsCopy[num4])
                            {
                                return true;
                            } // if
                        } // for
                        break;
                    } // block
            } // switch
            return false;
        } // ArrayHasChanged


        private bool CharacterIsInDelimiter(char testCharacter)
        {
            string[] textArray1 = this._Delimiters;
            for (int num1 = 0; num1 < textArray1.Length; num1++)
            {
                string text1 = textArray1[num1];
                if (text1.IndexOf(testCharacter) > -1)
                {
                    return true;
                } // if
            } // for
            return false;
        } // CharacterIsInDelimiter


        private void CheckCommentTokensForWhiteSpace(string[] tokens)
        {
            if (tokens != null)
            {
                string[] textArray1 = tokens;
                for (int num1 = 0; num1 < textArray1.Length; num1++)
                {
                    string text1 = textArray1[num1];
                    if (this._WhiteSpaceRegEx.IsMatch(text1))
                    {
                        throw new ArgumentException("CommentTokens", String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_WhiteSpaceInToken));
                    } // if
                } // for
            } // if
        } // CheckCommentTokensForWhiteSpace


        /// <summary>Closes the current TextFieldParser object.</summary>
        public void Close()
        {
            this.CloseReader();
        } // Close


        private void CloseReader()
        {
            this.FinishReading();
            if (this._Reader != null)
            {
                if (!this._LeaveOpen)
                {
                    this._Reader.Close();
                } // if
                this._Reader = null;
            } // if
        } // CloseReader


        /// <summary>Releases resources used by the <see cref="TextFieldParser"></see> object.</summary>
        public void Dispose()
        {
            this.Dispose(true);
            GC.SuppressFinalize(this);
        } // Dispose


        /// <summary>Releases resources used by the <see cref="TextFieldParser"></see> object.</summary>
        /// <param name="disposing">Boolean. True releases both managed and unmanaged resources; False releases only unmanaged resouces.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (!this._Disposed)
                {
                    this.Close();
                } // if
                this._Disposed = true;
            } // if
        } // Dispose





        private void FinishReading()
        {
            this._LineNumber = -1;
            this._EndOfData = true;
            this._Buffer = null;
            this._DelimiterRegex = null;
            this._BeginQuotesRegex = null;
        } // FinishReading


        private static int GetEndOfLineIndex(string Line)
        {
            int num2 = Line.Length;
            if (num2 != 1)
            {
                if ((String.Compare((Line[num2 - 2]).ToString(), "\r", true, CultureInfo.InvariantCulture) == 0) | (String.Compare((Line[num2 - 2]).ToString(), "\n", true, CultureInfo.InvariantCulture) == 0))
                {
                    return (num2 - 2);
                } // if
                if ((String.Compare((Line[num2 - 1]).ToString(), "\r", true, CultureInfo.InvariantCulture) == 0) | (String.Compare((Line[num2 - 1]).ToString(), "\n", true, CultureInfo.InvariantCulture) == 0))
                {
                    return (num2 - 1);
                } // if
            } // if
            return num2;
        } // GetEndOfLineIndex


        private string GetFixedWidthField(StringInfo Line, int Index, int FieldLength)
        {
            string text1;
            if (FieldLength > 0)
            {
                text1 = Line.SubstringByTextElements(Index, FieldLength);
            } // if
            else if (Index >= Line.LengthInTextElements)
            {
                text1 = string.Empty;
            } // if
            else
            {
                text1 = Line.SubstringByTextElements(Index).TrimEnd(new char[] { '\r', '\n' });
            } // else
            if (this._TrimWhiteSpace)
            {
                return text1.Trim();
            } // if
            return text1;
        } // GetFixedWidthField


        private bool IgnoreLine(string line)
        {
            if (line != null)
            {
                string text1 = line.Trim();
                if (text1.Length == 0)
                {
                    return true;
                } // if
                if (this._CommentTokens != null)
                {
                    string[] textArray1 = this._CommentTokens;
                    for (int num1 = 0; num1 < textArray1.Length; num1++)
                    {
                        string text2 = textArray1[num1];
                        if (String.Compare(text2, "", true, CultureInfo.InvariantCulture) != 0)
                        {
                            if (text1.StartsWith(text2, StringComparison.Ordinal))
                            {
                                return true;
                            } // if
                            if (line.StartsWith(text2, StringComparison.Ordinal))
                            {
                                return true;
                            } // if
                        } // if
                    } // for
                } // if
            } // if
            return false;
        } // IgnoreLine


        private int IncreaseBufferSize()
        {
            this._PeekPosition = this.m_CharsRead;
            int num1 = this._Buffer.Length + 0x1000;
            if (num1 > this._MaxBufferSize)
            {
                throw new InvalidOperationException(Resources.TextFieldParser_BufferExceededMaxSize);
            } // if
            char[] chArray1 = new char[(num1 - 1) + 1];
            Array.Copy(this._Buffer, chArray1, this._Buffer.Length);
            int num2 = this._Reader.Read(chArray1, this._Buffer.Length, 0x1000);
            this._Buffer = chArray1;
            this.m_CharsRead += num2;
            return num2;
        } // IncreaseBufferSize


        private void InitializeFromPath(string path, Encoding defaultEncoding, bool detectEncoding)
        {
            if (String.Compare(path, "", true, CultureInfo.InvariantCulture) == 0)
            {
                throw new ArgumentNullException("path");
            } // if
            if (defaultEncoding == null)
            {
                throw new ArgumentNullException("defaultEncoding");
            } // if
            string text1 = ValidatePath(path);
            FileStream stream1 = new FileStream(text1, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            this._Reader = new StreamReader(stream1, defaultEncoding, detectEncoding);
            this.ReadToBuffer();
        } // InitializeFromPath


        private void InitializeFromStream(Stream stream, Encoding defaultEncoding, bool detectEncoding)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");

            } // if
            if (!stream.CanRead)
            {
                throw new ArgumentException("stream", String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_StreamNotReadable, new string[] { "stream" }));

            } // if
            if (defaultEncoding == null)
            {
                throw new ArgumentNullException("defaultEncoding");
            } // if
            this._Reader = new StreamReader(stream, defaultEncoding, detectEncoding);
            this.ReadToBuffer();
        } // InitializeFromStream


        private string[] ParseDelimitedLine()
        {
            string text2 = this.ReadNextDataLine();
            if (text2 == null)
            {
                return null;
            } // if
            long num1 = this._LineNumber - 1;
            int num2 = 0;
            List<string> list1 = new List<string>();
            int num3 = GetEndOfLineIndex(text2);
            while (num2 <= num3)
            {
                string text1;
                Match match1 = null;
                bool flag1 = false;
                if (this._HasFieldsEnclosedInQuotes)
                {
                    match1 = this.BeginQuotesRegex.Match(text2, num2);
                    flag1 = match1.Success;
                } // if
                if (flag1)
                {
                    num2 = match1.Index + match1.Length;
                    QuoteDelimitedFieldBuilder builder1 = new QuoteDelimitedFieldBuilder(this._DelimiterWithEndCharsRegex, this._SpaceChars);
                    builder1.BuildField(text2, num2);
                    if (builder1.MalformedLine)
                    {
                        this._ErrorLine = text2.TrimEnd(new char[] { '\r', '\n' });
                        this._ErrorLineNumber = num1;
                        throw new MalformedLineException(String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_MalFormedDelimitedLine, new string[] { num1.ToString(CultureInfo.InvariantCulture) }), num1);
                    } // if
                    if (builder1.FieldFinished)
                    {
                        text1 = builder1.Field;
                        num2 = builder1.Index + builder1.DelimiterLength;
                    } // if
                    else
                    {
                        do
                        {
                            int num4 = text2.Length;
                            string text3 = this.ReadNextDataLine();
                            if (text3 == null)
                            {
                                this._ErrorLine = text2.TrimEnd(new char[] { '\r', '\n' });
                                this._ErrorLineNumber = num1;

                                throw new MalformedLineException(String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_MalFormedDelimitedLine, new string[] { num1.ToString(CultureInfo.InvariantCulture) }), num1);
                            } // if
                            if ((text2.Length + text3.Length) > this._MaxLineSize)
                            {
                                this._ErrorLine = text2.TrimEnd(new char[] { '\r', '\n' });
                                this._ErrorLineNumber = num1;

                                throw new MalformedLineException(String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_MaxLineSizeExceeded, new string[] { num1.ToString(CultureInfo.InvariantCulture) }), num1);
                            } // if
                            text2 = text2 + text3;
                            num3 = GetEndOfLineIndex(text2);
                            builder1.BuildField(text2, num4);
                            if (builder1.MalformedLine)
                            {
                                this._ErrorLine = text2.TrimEnd(new char[] { '\r', '\n' });
                                this._ErrorLineNumber = num1;

                                throw new MalformedLineException(String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_MalFormedDelimitedLine, new string[] { num1.ToString(CultureInfo.InvariantCulture) }), num1);
                            } // if
                        }
                        while (!builder1.FieldFinished);
                        text1 = builder1.Field;
                        num2 = builder1.Index + builder1.DelimiterLength;
                    } // else
                    if (this._TrimWhiteSpace)
                    {
                        text1 = text1.Trim();
                    } // if
                    list1.Add(text1);
                    continue;
                } // if
                Match match2 = this._DelimiterRegex.Match(text2, num2);
                if (match2.Success)
                {
                    text1 = text2.Substring(num2, match2.Index - num2);
                    if (this._TrimWhiteSpace)
                    {
                        text1 = text1.Trim();
                    } // if
                    list1.Add(text1);
                    num2 = match2.Index + match2.Length;
                    continue;
                } // if
                text1 = text2.Substring(num2).TrimEnd(new char[] { '\r', '\n' });
                if (this._TrimWhiteSpace)
                {
                    text1 = text1.Trim();
                } // if
                list1.Add(text1);
                break;
            } // while
            return list1.ToArray();
        } // ParseDelimitedLine


        private string[] ParseFixedWidthLine()
        {
            string text1 = this.ReadNextDataLine();
            if (text1 == null)
            {
                return null;
            } // if
            text1 = text1.TrimEnd(new char[] { '\r', '\n' });
            StringInfo info1 = new StringInfo(text1);
            this.ValidateFixedWidthLine(info1, this._LineNumber - 1);
            int num2 = 0;
            int num1 = this._FieldWidths.Length - 1;
            string[] textArray1 = new string[num1 + 1];
            int num4 = num1;
            for (int num3 = 0; num3 <= num4; num3++)
            {
                textArray1[num3] = this.GetFixedWidthField(info1, num2, this._FieldWidths[num3]);
                num2 += this._FieldWidths[num3];
            } // for
            return textArray1;
        } // ParseFixedWidthLine


        /// <summary>Reads the specified number of characters without advancing the cursor.</summary>
        /// <returns>String.</returns>
        /// <param name="numberOfChars">Int32. Number of characters to read. Required. </param>
        public string PeekChars(int numberOfChars)
        {
            if (numberOfChars <= 0)
            {
                throw new ArgumentException("numberOfChars", String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_NumberOfCharsMustBePositive, new string[] { "numberOfChars" }));
            } // if
            if ((this._Reader == null) | (this._Buffer == null))
            {
                return null;
            } // if
            if (this._EndOfData)
            {
                return null;
            } // if
            string text1 = this.PeekNextDataLine();
            if (text1 == null)
            {
                this._EndOfData = true;
                return null;
            } // if
            text1 = text1.TrimEnd(new char[] { '\r', '\n' });
            if (text1.Length < numberOfChars)
            {
                return text1;
            } // if
            StringInfo info1 = new StringInfo(text1);
            return info1.SubstringByTextElements(0, numberOfChars);
        } // PeekChars


        private string PeekNextDataLine()
        {
            string text1;
            ChangeBufferFunction function1 = new ChangeBufferFunction(this.IncreaseBufferSize);
            this.SlideCursorToStartOfBuffer();
            this._PeekPosition = 0;
            do
            {
                text1 = this.ReadNextLine(ref this._PeekPosition, function1);
            }
            while (this.IgnoreLine(text1));
            return text1;
        } // PeekNextDataLine


        /// <summary>Reads all fields on the current line, returns them as an array of strings, and advances the cursor to the next line containing data.</summary>
        /// <returns>String ().</returns>
        public string[] ReadFields()
        {
            if (!((this._Reader == null) | (this._Buffer == null)))
            {
                this.ValidateReadyToRead();
                switch (this._TextFieldType)
                {
                    case FieldType.Delimited:
                        {
                            return this.ParseDelimitedLine();
                        } // block
                    case FieldType.FixedWidth:
                        {
                            return this.ParseFixedWidthLine();
                        } // block
                } // switch
            } // if
            return null;
        } // ReadFields


        /// <summary>Returns the current line as a string and advances the cursor to the next line.</summary>
        /// <returns>String</returns>
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        public string ReadLine()
        {
            if ((this._Reader == null) | (this._Buffer == null))
            {
                return null;
            } // if
            ChangeBufferFunction function1 = new ChangeBufferFunction(this.ReadToBuffer);
            string text1 = this.ReadNextLine(ref this._Position, function1);
            if (text1 == null)
            {
                this.FinishReading();
                return null;
            } // if
            this._LineNumber++;
            return text1.TrimEnd(new char[] { '\r', '\n' });
        } // ReadLine


        private string ReadNextDataLine()
        {
            string text1;
            ChangeBufferFunction function1 = new ChangeBufferFunction(this.ReadToBuffer);
            do
            {
                text1 = this.ReadNextLine(ref this._Position, function1);
                this._LineNumber++;
            }
            while (this.IgnoreLine(text1));
            if (text1 == null)
            {
                this.CloseReader();
            } // if
            return text1;
        } // ReadNextDataLine


        private string ReadNextLine(ref int Cursor, ChangeBufferFunction ChangeBuffer)
        {
            if ((Cursor == this.m_CharsRead) && (ChangeBuffer() == 0))
            {
                return null;
            } // if
            StringBuilder builder1 = null;
            while (true)
            {
                int num3 = this.m_CharsRead - 1;
                for (int num2 = Cursor; num2 <= num3; num2++)
                {
                    char ch1 = this._Buffer[num2];
                    if ((String.Compare(ch1.ToString(), "\r", true, CultureInfo.InvariantCulture) == 0) | (String.Compare(ch1.ToString(), "\n", true, CultureInfo.InvariantCulture) == 0))
                    {
                        if (builder1 != null)
                        {
                            builder1.Append(this._Buffer, Cursor, (num2 - Cursor) + 1);
                        } // if
                        else
                        {
                            builder1 = new StringBuilder(num2 + 1);
                            builder1.Append(this._Buffer, Cursor, (num2 - Cursor) + 1);
                        } // else
                        Cursor = num2 + 1;
                        if (String.Compare(ch1.ToString(), "\r", true, CultureInfo.InvariantCulture) == 0)
                        {
                            if (Cursor < this.m_CharsRead)
                            {
                                if (String.Compare((this._Buffer[Cursor]).ToString(), "\n", true, CultureInfo.InvariantCulture) == 0)
                                {
                                    Cursor += 1;
                                    builder1.Append("\n");
                                } // if
                            } // if
                            else if ((ChangeBuffer() > 0) && (String.Compare((this._Buffer[Cursor]).ToString(), "\n", true, CultureInfo.InvariantCulture) == 0))
                            {
                                Cursor += 1;
                                builder1.Append("\n");
                            } // if
                        } // if
                        return builder1.ToString();
                    } // if
                } // for
                int num1 = this.m_CharsRead - Cursor;
                if (builder1 == null)
                {
                    builder1 = new StringBuilder(num1 + 10);
                } // if
                builder1.Append(this._Buffer, Cursor, num1);
                if (ChangeBuffer() <= 0)
                {
                    return builder1.ToString();
                } // if
            } // while
        } // ReadNextLine


        private int ReadToBuffer()
        {
            this._Position = 0;
            int num1 = this._Buffer.Length;
            if (num1 > 0x1000)
            {
                num1 = 0x1000;
                this._Buffer = new char[(num1 - 1) + 1];
            } // if
            this.m_CharsRead = this._Reader.Read(this._Buffer, 0, num1);
            return this.m_CharsRead;
        } // ReadToBuffer


        /// <summary>Reads the remainder of the text file and returns it as a string.</summary>
        /// <returns>String.</returns>
        [EditorBrowsable(EditorBrowsableState.Advanced)]
        public string ReadToEnd()
        {
            if ((this._Reader == null) | (this._Buffer == null))
            {
                return null;
            } // if
            StringBuilder builder1 = new StringBuilder(this._Buffer.Length);
            builder1.Append(this._Buffer, this._Position, this.m_CharsRead - this._Position);
            builder1.Append(this._Reader.ReadToEnd());
            this.FinishReading();
            return builder1.ToString();
        } // ReadToEnd



        /// <summary>Sets the delimiters for the reader to the specified values, and sets the field type to Delimited.</summary>
        /// <param name="delimiters">Array of type String. </param>
        public void SetDelimiters(params string[] delimiters)
        {
            this.Delimiters = delimiters;
        } // SetDelimiters


        /// <summary>Sets the delimiters for the reader to the specified values and the field type to FixedWidth.</summary>
        /// <param name="fieldWidths">Array of Integer. </param>
        public void SetFieldWidths(params int[] fieldWidths)
        {
            this.FieldWidths = fieldWidths;
        } // SetFieldWidths


        private int SlideCursorToStartOfBuffer()
        {
            if (this._Position > 0)
            {
                int num2 = this._Buffer.Length;
                char[] chArray1 = new char[(num2 - 1) + 1];
                Array.Copy(this._Buffer, this._Position, chArray1, 0, num2 - this._Position);
                int num3 = this._Reader.Read(chArray1, num2 - this._Position, this._Position);
                this.m_CharsRead = (this.m_CharsRead - this._Position) + num3;
                this._Position = 0;
                this._Buffer = chArray1;
                return num3;
            } // if
            return 0;
        } // SlideCursorToStartOfBuffer



        private void ValidateAndEscapeDelimiters()
        {
            if (this._Delimiters == null)
            {
                throw new ArgumentException("Delimiters", String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_DelimitersNothing, new string[] { "Delimiters" }));

            } // if
            if (this._Delimiters.Length == 0)
            {
                throw new ArgumentException("Delimiters", String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_DelimitersNothing, new string[] { "Delimiters" }));

            } // if
            int num1 = this._Delimiters.Length;
            StringBuilder builder1 = new StringBuilder();
            StringBuilder builder2 = new StringBuilder();
            builder2.Append(this.EndQuotePattern + "(");
            int num3 = num1 - 1;
            for (int num2 = 0; num2 <= num3; num2++)
            {
                if (this._Delimiters[num2] != null)
                {
                    if (this._HasFieldsEnclosedInQuotes && (this._Delimiters[num2].IndexOf('"') > -1))
                    {
                        throw new InvalidOperationException(Resources.TextFieldParser_IllegalDelimiter);


                    } // if
                    string text1 = Regex.Escape(this._Delimiters[num2]);
                    builder1.Append(text1 + "|");
                    builder2.Append(text1 + "|");
                } // if
            } // for
            this._SpaceChars = this.WhiteSpaceCharacters;
            this._DelimiterRegex = new Regex(builder1.ToString(0, builder1.Length - 1), RegexOptions.CultureInvariant);
            builder1.Append("\r|\n");
            this._DelimiterWithEndCharsRegex = new Regex(builder1.ToString(), RegexOptions.CultureInvariant);
            builder2.Append("\r|\n)|\"$");
        } // ValidateAndEscapeDelimiters


        private static void ValidateDelimiters(string[] delimiterArray)
        {
            if (delimiterArray != null)
            {
                string[] textArray1 = delimiterArray;
                for (int num1 = 0; num1 < textArray1.Length; num1++)
                {
                    string text1 = textArray1[num1];
                    if (String.Compare(text1, "", true, CultureInfo.InvariantCulture) == 0)
                    {
                        throw new ArgumentException("Delimiters", String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_DelimiterNothing, new string[] { "Delimiters" }));


                    } // if
                    if (text1.IndexOfAny(new char[] { '\r', '\n' }) > -1)
                    {
                        throw new ArgumentException("Delimiters", String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_EndCharsInDelimiter));

                    } // if
                } // for
            } // if
        } // ValidateDelimiters


        private static void ValidateFieldTypeEnumValue(FieldType value, string paramName)
        {
            if ((value < FieldType.Delimited) || (value > FieldType.FixedWidth))
            {
                throw new InvalidEnumArgumentException(paramName, (int)value, typeof(FieldType));
            } // if
        } // ValidateFieldTypeEnumValue


        private void ValidateFieldWidths()
        {
            if (this._FieldWidths == null)
            {
                throw new InvalidOperationException(Resources.TextFieldParser_FieldWidthsNothing);


            } // if
            if (this._FieldWidths.Length == 0)
            {
                throw new InvalidOperationException(Resources.TextFieldParser_FieldWidthsNothing);

            } // if
            int num1 = this._FieldWidths.Length - 1;
            this._LineLength = 0;
            int num3 = num1 - 1;
            for (int num2 = 0; num2 <= num3; num2++)
            {
                this._LineLength += this._FieldWidths[num2];
            } // for
            if (this._FieldWidths[num1] > 0)
            {
                this._LineLength += this._FieldWidths[num1];
            } // if
        } // ValidateFieldWidths


        private static void ValidateFieldWidthsOnInput(int[] Widths)
        {
            int num1 = Widths.Length - 1;
            int num3 = num1 - 1;
            for (int num2 = 0; num2 <= num3; num2++)
            {
                if (Widths[num2] < 1)
                {
                    throw new ArgumentException("FieldWidths", String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_FieldWidthsMustPositive, new string[] { "FieldWidths" }));
                } // if
            } // for
        } // ValidateFieldWidthsOnInput


        private void ValidateFixedWidthLine(StringInfo Line, long lineNumber)
        {
            if (Line.LengthInTextElements < this._LineLength)
            {
                this._ErrorLine = Line.String;
                this._ErrorLineNumber = this._LineNumber - 1;
                throw new MalformedLineException(String.Format(CultureInfo.InvariantCulture, Resources.TextFieldParser_MalFormedFixedWidthLine, new string[] { LineNumber.ToString(CultureInfo.InvariantCulture) }), lineNumber);
            } // if
        } // ValidateFixedWidthLine


        private static string ValidatePath(string path)
        {
            string text1 = FileSystem.NormalizeFilePath(path, "path");
            if (!File.Exists(text1))
            {

                throw new FileNotFoundException(String.Format(CultureInfo.InvariantCulture, Resources.IO_FileNotFound_Path, new string[] { text1 }), text1);
            } // if
            return text1;
        } // ValidatePath



        private void ValidateReadyToRead()
        {
            if (this._NeedPropertyCheck | this.ArrayHasChanged())
            {
                switch (this._TextFieldType)
                {
                    case FieldType.Delimited:
                        {
                            this.ValidateAndEscapeDelimiters();
                            break;
                        } // block
                    case FieldType.FixedWidth:
                        {
                            this.ValidateFieldWidths();
                            break;
                        } // block
                } // switch
                if (this._CommentTokens != null)
                {
                    string[] textArray1 = this._CommentTokens;
                    for (int num1 = 0; num1 < textArray1.Length; num1++)
                    {
                        string text1 = textArray1[num1];
                        if (((String.Compare(text1, "", true, CultureInfo.InvariantCulture) != 0) && (this._HasFieldsEnclosedInQuotes & (this._TextFieldType == FieldType.Delimited))) && (string.Compare(text1.Trim(), "\"", StringComparison.Ordinal) == 0))
                        {
                            throw new InvalidOperationException(Resources.TextFieldParser_InvalidComment);

                        } // if
                    } // for
                } // if
                this._NeedPropertyCheck = false;
            } // if
        } // ValidateReadyToRead

        #endregion
    }
}
